Published: Jul 9, 20234 min read

Integrating Office 365 into Home Assistant

Written by: Fixt
Calendar
Mail
Teams
To Do

Office 365 Integration Install

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

You can find the documentation here.

  1. How to install File Editor Addon here.
  2. How to create a secret here.

YAML config

config/configuration.yaml

o365:
  accounts:
    - account_name: Fixt # Do not use email address or spaces
      client_id: !secret office365_client_id
      client_secret: !secret office365_client_secret
      enable_update: True
      email_sensor:
        - name: inbox
          max_items: 10
          is_unread: True
          download_attachments: False
      query_sensors:
        - name: "Example"
          folder: "Inbox/Test_Inbox" #Default is Inbox
          from: "[email protected]"
          subject_contains: "Example subject"
          has_attachment: true
          max_items: 2
          is_unread: true
      status_sensors: # Cannot be used for personal accounts
        - name: "Fixt Teams Status"
      chat_sensors: # Cannot be used for personal accounts
        - name: "Fixt Chat"
          enable_update: True
      todo_sensors:
        enabled: True
        enable_update: True #Needed to activate update services
      auto_reply_sensors:
        - name: "Fixt AutoReply" 

Automation Examples

Example automation to know if you are in a meeting

config/automations.yaml

alias: Teams Meeting Status
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.fixt_teams_status
condition: []
action:
  - choose:
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: sensor.fixt_teams_status
                state: InACall
              - condition: state
                entity_id: sensor.fixt_teams_status
                state: InAConferenceCall
              - condition: state
                entity_id: sensor.fixt_teams_status
                state: Presenting
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.inameeting
    default:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.inameeting
mode: single

Example automation to notify you when you receive an email from a specific sender

config/automations.yaml

alias: Notify Fixt of Client Email
trigger:
- platform: state
  entity_id: sensor.client_a_email
condition:
- condition: and
  conditions:
  #Prevents multiple notifications for the same email
  - condition: template
    value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
  - condition: template
    value_template: '{{ states.sensor.helpdesk.state  != ''0'' }}'
  #Only allow notification on non office days
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'off'
  - condition: time
    after: '10:00:00'
    before: '22:00:00'
action:
#Send notification to phone with the subject of the email
- service: notify.fixt
  data_template:
    message: '{{states.sensor.helpdesk.attributes.data[0]["subject"]}}'

Teams integration states list

  • Available
  • Away
  • BeRightBack
  • Busy
  • DoNotDisturb
  • InACall
  • InAConferenceCall
  • Inactive
  • InAMeeting
  • Offline
  • OffWork
  • OutOfOffice
  • PresenceUnknown
  • Presenting
  • UrgentInterruptionsOnly

How to create a helper

Open your Home Assistant instance and show your helper entities.

You can use this button to go to the helpers page and create a input_boolean (Toggle) using the user interface .